package com.neusoft.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.neusoft.mapper.FoodMapper;
import com.neusoft.po.Food;
import com.neusoft.service.FoodService;

@Service
public class FoodServiceImpl implements FoodService {

	@Autowired
	private FoodMapper foodMapper;

	// 根据商家编号查询所属食品信息
	@Override
	public List<Food> listFoodByBusinessId(Integer businessId) {
		return foodMapper.listFoodByBusinessId(businessId);
	}
	
	// 根据食品编号查询食品信息
	@Override
	public Food getFoodById(Integer foodId) {
		return foodMapper.getFoodById(foodId);
	}

	@Override
	public int updateFood(Integer foodId, Integer foodPrice) {
		int a = foodMapper.updateFoodStatus(foodId);
		int b = 0;
		Food food = getFoodById(foodId);
		food.setFoodPrice(foodPrice);
		b = foodMapper.saveFood(food);
		return a & b;
	}

}